<template>
    <div >
        <el-button type="text" @click="dialogVisible = true">选择图片</el-button>

        <el-dialog title="提示" :visible.sync="dialogVisible" width="50%" :before-close="handleClose" >
            <el-carousel :autoplay="false" type="card" height="300px" @change="lisChange">
                <el-carousel-item v-for="(item,index) in surveyImage" :key="index" >
                    <!-- <h3 >{{ item }}</h3> -->
                    <img :src="domAddress+item" alt="" style="width: 100%;,height: 100%;">
                </el-carousel-item>
            </el-carousel>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="confirmSelect">确认选择</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    props: ['surveyImage','index'],
    watch:{
    
            surveyImage:{
            handler(newData, oldData) {
                this.displayImage=newData[0]
            },
        }
    },


    data() {
        return {
            dialogVisible: false,
            allImage:[],
            displayImage:'',
            domAddress: 'http://192.168.10.233:86'
        }
        
    },
    name:'selectAlertImage',
    methods: {
      handleClose(done) {
        this.dialogVisible=false
      },
      lisChange(index){
        this.displayImage=this.surveyImage[index]
      },
      confirmSelect(){
        if(typeof this.index === "undefined"){
            this.$emit('message',this.displayImage);
        }else{
      
        this.$emit('message',{data:this.displayImage,index:this.index});
        }
        this.dialogVisible=false

      }
    }
}
</script>
<style>
.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
}
</style>